let list = [];
let count = new Array(21);
count.fill(0);
fillCanvas(context, "black");

for (let i = 0; i < 50000; i++) {
    let ran = setRandomNumber(0, 20, 20);
    let string = "";
    for (let j = 0; j < ran.length; j++) {
        count[ran[j]]++;
    }
    fillCanvas(context, "black");
    drawChart(count);
}
showWindow(10, 10, "white", list);

function drawChart(array){
    context.textAlign = "center";
    context.textBaseline = "middle";
    context.fillStyle = "white";
    context.font = "20px 黑体";
    context.save();
    context.translate(canvas.width / 2 - 420, canvas.height - 200);
    for (let i=0; i<21; i++){
        context.fillText(array[i].toString(), i*40, 50);
        context.fillText(i.toString(), i*40, 100);
    }
    context.restore();
}